package com.example.springboot.mapper;

import com.example.springboot.entity.Approve;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/*
 * 功能：审批界面——
 * 日期：2024-5-9 20:20
 * 作者：RabbitQ
 */

@Mapper
public interface ApproveMapper {

    //审批界面——选择所有审批数据
    @Select("select * from `approve` ")
    List<Approve> selectAllApprove();


    //审批界面——更新签名图url——通过数据的id
    @Update("update `approve` set  imageUrl = #{imageUrl}, " +
            "approveDate = #{approveDate}, approveStatus = #{approveStatus}, approveDate = #{approveDate} " +
            "where id = #{id}")
    void updateUrlByID(Approve approve);


    //审批界面——更新审批状态——通过数据的id
    @Update("update `approve` set  approveStatus = #{approveStatus} " +
            "where id = #{id}")
    void updateStatusByID(Approve approve);

    //审批界面——撤销审批——通过数据的id
    @Delete("delete from `approve` where id=#{id}")
    void deleteApproveByID(Approve approve);

    //审批界面——通过负责人和状态进行筛选
    @Select("select * from `approve` where charger=#{charger}  and approveStatus=#{status}")
    List<Approve> selectByChargerStatus(String charger, String status);

    //审批界面——通过负责人进行筛选
    @Select("select * from `approve` where charger=#{charger}")
    List<Approve> selectByCharger(String charger);

    //审批界面——通过状态进行筛选
    @Select("select * from `approve` where approveStatus=#{status}")
    List<Approve> selectByStatus(String status);

}
